package com.frank.yinyuetai.Fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.frank.yinyuetai.Adapter.RelativeMvRecycleAdapter;
import com.frank.yinyuetai.Bean.VideoBean;
import com.frank.yinyuetai.R;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2016/8/17 0017.
 */
public class MVRelativeFragment extends Fragment {
    @Bind(R.id.rv_relative)
    RecyclerView recyclerView;
    private VideoBean vBean;
    private RelativeMvRecycleAdapter adapter;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.relative_fragment, null);
        vBean = (VideoBean) getArguments().getSerializable("videoBean");
        ButterKnife.bind(this, view);
        initData();
        return view;
    }

    private void initData() {
        adapter = new RelativeMvRecycleAdapter(getActivity(), vBean.getRelatedVideos());
        recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
        recyclerView.setAdapter(adapter);
    }

    public static MVRelativeFragment newInstance(VideoBean videoBean) {
        MVRelativeFragment fragment = new MVRelativeFragment();
        Bundle bundle = new Bundle();
        bundle.putSerializable("videoBean", videoBean);
        fragment.setArguments(bundle);
        return fragment;
    }
}
